package org.fenixsoft.log;

import java.io.Writer;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

import javax.servlet.AsyncContext;

import org.apache.log4j.Layout;
import org.apache.log4j.WriterAppender;

/**
 * 基于AsyncContext支持的Appender
 * @author zzm
 */
public class WebLogAppender extends WriterAppender {

	/**
	 * 异步Servlet上下文队列
	 */
	public static final Queue<AsyncContext> ASYNC_CONTEXT_QUEUE = new ConcurrentLinkedQueue<AsyncContext>();

	/**
	 * AsyncContextQueue Writer
	 */
	private Writer writer = new AsyncContextQueueWriter(ASYNC_CONTEXT_QUEUE);

	public WebLogAppender() {
		setWriter(writer);
	}

	public WebLogAppender(Layout layout) {
		this();
		super.layout = layout;
	}

}
